home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 089a.dms / 089a.adf / EXAMPLE_PROGRAMS / example25.AMOS / example25.amosSourceCode < prev    next >
AMOS Source Code  |  1992-03-06  |  3KB  |  75 lines

  1. 'The beginnings of a ship thingy. It could be anything you want! 
  2. '
  3. Rem Hide the mouse pointer and unpack the picture I have stored in bank 10 
  4. Rem set double buffer to cut down on flicker.
  5. '------------------------------------------------------------------------- 
  6. Hide 
  7. Unpack 10 To 0
  8. Double Buffer 
  9. '
  10. Rem Set the following variables to be used inside and outside
  11. Rem of procedures. 
  12. '------------------------------------------------------------- 
  13. Global XOFF,YOFF
  14.  
  15.  
  16. Rem Set up the varaiables: 
  17. Rem XOFF is the x offset of the screen display 
  18. Rem YOFF is Y offset 
  19. Rem AC is the x position of the ship 
  20. Rem DWN is the y position of the ship, not used in this example. 
  21. Rem IMAGE is the bob bank image number being used for the ship,
  22. Rem image 2 is the ship facing right Image 3 facing left 
  23. Rem X means horizontal,left<>right,  Y means vertical    
  24. '--------------------------------------------------------------
  25. XOFF=0 : YOFF=0 : AC=100 : DWN=150 : IMAGE=2
  26.  
  27. Rem The main loop
  28. '----------------
  29. Do 
  30.  
  31. Rem place the bob 1 at the coordinates ac,dwn (across,down) image will 
  32. Rem be set to the correct direction. 
  33. '----------------------------------------------------------------------
  34. Bob 1,AC,DWN,IMAGE
  35.  
  36. Rem now deal with thejoystick. We are only interested in left and right movement.  
  37. Rem if pressed to right then we INCrease xoff by one, updated the bobs position
  38. Rem by INCreasing AC then make sure IMAGE is equal to 2 pointing right 
  39. If Jright(1) Then Inc XOFF : Inc AC : IMAGE=2
  40.  
  41. Rem for joystick left is virtually the same except using DECrease and image 3
  42. If Jleft(1) Then Dec XOFF : Dec AC : IMAGE=3
  43.  
  44. Rem the following lines make sure the ship stays inside the screen 
  45. Rem if AC=0 then the ship has reached the left edge of the screen to stop
  46. Rem it going off the edge we make sure AC stays at a minimum of 0. 
  47. Remthe right is is 896 we do the same. It's896 because the loaded picture is that wide.
  48. '--------------------------------------------------------------------------------------
  49. If AC<0 Then AC=0
  50. If AC>896 Then AC=896
  51.  
  52. Rem call the _UPD procedure which scrolls the screen 
  53. _UPD
  54.  
  55. Rem this slows things down and keeps it smooth 
  56. Rem try it without to see what you think.
  57. '----------------------------------------------------
  58. Wait Vbl 
  59.  
  60. Rem the end of the main loop, jumps back to the DO command.
  61. Loop 
  62.  
  63.  
  64. Procedure _UPD
  65. Rem this stops the screen scrolling too far like in the AC bit above 
  66. '------------------------------------------------------------------- 
  67.  If XOFF<0 Then XOFF=0
  68.  If XOFF>620 : XOFF=620 : End If 
  69.  If YOFF<0 Then YOFF=0
  70.  If YOFF>200 : YOFF=0 : End If 
  71.  
  72. Rem This is what scrolls the background,   
  73. '----------------------------------------- 
  74. Screen Offset 0,XOFF,YOFF
  75. End Proc